<template>
	<view>
		<u-sticky>
			<view class="top">
				<view style="padding: 50rpx; padding-top: 50rpx;">
					<view style="font-weight: 800;text-overflow: ellipsis;white-space: nowrap;width: 20rem; overflow: hidden;margin-top: 150rpx;">{{lawdata.title}}</view>
					<view>
						<view style="display: flex; flex-direction: row; justify-content: ;width: 100%; justify-content: flex-start; margin-top: 20rpx;">
							<u-tag :text="swapvalid(lawdata.status)" plain size="mini" type="success" style="margin-left: 30rpx;"></u-tag>
							<u-tag :text="lawTypeswap(lawdata.type)" plain size="mini" type="error" style="margin-left: 30rpx;"></u-tag>
							<u-tag :text="lawdata.pubunitname" plain size="mini" type="primary" style="margin-left: 30rpx; text-align: center;"></u-tag>
						</view>
					</view>
				</view>
			</view>
		</u-sticky>
		
		
		
		<view style="background-color: #FFFFFF;">
			<u-collapse
			    @change="change"
			    @close="close"
			    @open="open"
				v-model="activeNames"
			  >
			    <u-collapse-item
			      title=""
			      :name="index"
				  v-for="(item,index) in listData" :key="item.id"
				  class="u-page__item"
			    >
				<text slot="title" class="u-page__item__title__slot-title" style="color: #FFFFFF;">{{item.title}}</text>
			      <view class="u-collapse-content">{{item.content}}</view>
			    </u-collapse-item>
			  </u-collapse>
		</view>

		<!-- 空状态 -->
		<u-empty v-if="listDataEmpty" text="暂无详情记录"mode="data">
		</u-empty>
		<!-- toast提示框 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	
	import { getLawItemDetail } from '@/common/api/approve/home/law_provision.js'
	
	
	export default {
		data() {
			return {
				listDataEmpty: false,  //列表数据是否为空
				status: 'loadmore', //加载的状态
				loadText: { // 下拉文字
					loadmore: '上拉加载更多',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
				activeNames: [], //默认展开哪些项
				docid: '',
				listData: [],
				// activeKey: [],
				lawdata: {},
				lawTypeList: [
					{
						name: '法律',
						value: '6300100'
					},
					{
						name: '行政法规',
						value: '6300101'
					},
					{
						name: '地方法规',
						value: '6300102'
					},
					{
						name: '部门规章',
						value: '6300103'
					},
					{
						name: '地方规章',
						value: '6300104'
					},
					{
						name: '规范性文件',
						value: '6300105'
					},
					{
						name: '司法解释',
						value: '6300106'
					}
					], // 法律性质下拉框数据
			}
		},
		onLoad(item) {
			this.lawdata = JSON.parse(item.item)
			this.docid=this.lawdata.id
			this.getDetailData()
		},
		methods: {
			change(){},
			close(){},
			open(){},
			swapvalid(number){
				if(number=='6300200') return '有效'
				else if(number=='6300201') return '失效'
				else if(number=='6300202') return '已修订'
				else if(number=='6300203') return '尚未实施'
			},
			//法律类型转换
			lawTypeswap(number){
				for (let index in this.lawTypeList) {
					if(number==this.lawTypeList[index].value) return this.lawTypeList[index].name
					else continue
				}
			},
			/**
			 * 获取法律条文的具体细项数据
			 */
			getDetailData() {
				console.log("方法里",this.docid)
			  getLawItemDetail({docid: this.docid}).then((res) => {
			    if (res.code !== 0) {
				  this.$refs.uToast.show({
				      position: 'center',
				      message: '获取数据失败',
				      type: 'error'
				  })
			    } else {
			      this.listData = res.data
				  if(this.listData.length==0) this.listDataEmpty=true
			      for (let index in this.listData) {
					this.activeNames.push(index)
			      }
			    }
			  })
			},
		}
	}
</script>

<style scoped lang="scss">
.top{
	width: 100%;
	height: 375rpx;
	background-image: url('@/static/lawtop.png');
	background-size: cover;
}
.u-page__item{
	width: 90%;
	margin-left: 5%;
	margin-top: 30rpx;
}
::v-deep .u-cell__body{
	background-color: #2149A3;
	border-radius: 10pt 10pt 0 0;
}

</style>
